package edu.scu.declaresys.vo;

import java.util.Date;

import edu.scu.declaresys.dao.util.Column;
import edu.scu.declaresys.dao.util.FieldWalker;
import edu.scu.declaresys.dao.util.Table;


/**
 * 
 * @author: zt
 * @since : 2013-7-3
 */
@Table(code = News.T_TABLE)
public class News implements java.io.Serializable
{
	private static final long	serialVersionUID	= 8549416482745562851L;
	//
	// table column name.
	//
	public static final String	T_TABLE				= "news";
	public static final String	T_ID				= "id";
	public static final String	T_NEWS_CLASS_ID		= "newsClassId";
	public static final String	T_TITLE				= "title";
	public static final String	T_CONTENT			= "content";
	public static final String	T_PUBLISH_TIME		= "publishTime";
	//
	// Fields
	//
	@Column(code = T_ID)
	private Integer				id;
	@Column(code = T_NEWS_CLASS_ID)
	private Integer				newsClassId;
	@Column(code = T_TITLE)
	private String				title;
	@Column(code = T_CONTENT)
	private String				content;
	@Column(code = T_PUBLISH_TIME)
	private Date				publishTime;
	//
	// References
	//
	private NewsClass newsClass;
	//
	// Constructors
	//
	/** default constructor */
	public News()
	{
	}
	
	/** full constructor */
	public News(Integer newsClassId, String title, String content,
			Date publishTime)
	{
		this.newsClassId = newsClassId;
		this.title = title;
		this.content = content;
		this.publishTime = publishTime;
	}
	//
	// Override functions.
	//
	public String toString()
	{
		return FieldWalker.makeNonstaticFields(this, FieldWalker.WITHOUT_NULL);
	}
	
	@Override
	public int hashCode()
	{
		return id.hashCode();
	}

	@Override
	public boolean equals(Object obj)
	{
		if(this == obj)
		{
			return true;
		}
		if(obj == null)
		{
			return false;
		}
		if(!(obj instanceof News))
		{
			return false;
		}
		//
		return this.id.equals(((News)obj).id);
	}
	
	
	//
	// Getters and Setters.
	//
	public Integer getId()
	{
		return this.id;
	}
	
	public void setId(Integer id)
	{
		this.id = id;
	}
	
	public Integer getNewsClassId()
	{
		return this.newsClassId;
	}
	
	public void setNewsClassId(Integer newsClassId)
	{
		this.newsClassId = newsClassId;
	}
	
	public String getTitle()
	{
		return this.title;
	}
	
	public void setTitle(String title)
	{
		this.title = title;
	}
	
	public String getContent()
	{
		return this.content;
	}
	
	public void setContent(String content)
	{
		this.content = content;
	}
	
	public Date getPublishTime()
	{
		return this.publishTime;
	}
	
	public void setPublishTime(Date publishTime)
	{
		this.publishTime = publishTime;
	}

	public NewsClass getNewsClass()
	{
		return newsClass;
	}

	public void setNewsClass(NewsClass newsClass)
	{
		this.newsClass = newsClass;
	}
	
}
